// 样式-数据-开启合计
import React from 'react';
import DragContainer from 'src/pages/AnalyseManage/EditReport/components/EditorDataType/Drag/DragContainer';
import FormItem from 'antd/lib/form/FormItem';

interface IProps {
	config: any;
	onValuesChange: ( chartType: string, key: string, values: Object, configType: string ) => void;
	form: any;
	currentDragNode: any;
	dragOver: any;
	type: 'valueFieldsMeasure' | 'valueFieldsDimension' | 'valueFieldsDate';
}

const ValueFields = ( props: IProps ) => {
	const { config, form, onValuesChange, currentDragNode, dragOver, type } = props;
	return (
		<>
			{type === 'valueFieldsMeasure' && (
				<FormItem label="取值字段" name="valueFields">
					<DragContainer
						form={form}
						name="valueFields"
						tip="拖入维度"
						limit={1}
						config={config}
						dragOver={dragOver}
						currentDragNode={currentDragNode}
						onValuesChange={onValuesChange}
					></DragContainer>
				</FormItem>
			)}
			{type === 'valueFieldsDimension' && (
				<FormItem label="取值字段" name="valueFields">
					<DragContainer
						form={form}
						name="valueFields"
						tip="拖入度量"
						type="measure"
						limit={1}
						config={config}
						dragOver={dragOver}
						currentDragNode={currentDragNode}
						onValuesChange={onValuesChange}
					></DragContainer>
				</FormItem>
			)}
			{type === 'valueFieldsDate' && (
				<FormItem label="取值字段" name="valueFields">
					<DragContainer
						form={form}
						name="valueFields"
						tip="拖入日期"
						type="date"
						limit={1}
						config={config}
						dragOver={dragOver}
						currentDragNode={currentDragNode}
						onValuesChange={onValuesChange}
					></DragContainer>
				</FormItem>
			)}
		</>
	);
};

export default React.memo( ValueFields );
